<template>
	<view class="examCard" @click="handleClick(examGradItem.id)">
		<view class="top">
			<view class="title">{{examGradItem.examName}}</view>
			<u-tag class="tag" :text="state" :type="stateType" />
		</view>
		<view class="middle">
			<view class="left">
				<view v-if="examGradItem.examTime>0">总分<text>{{examGradItem.totalScore}}</text>分 &ensp;
					耗时<text>{{examGradItem.examTime}}</text></view>
				<view v-else>总分<text>{{examGradItem.totalScore}}</text>分</view>
				<view>{{examGradItem.handPaperTime}}</view>
			</view>

			<view class="right" v-if="examGradItem.scoreState==2">
				<view class="gradeNum">
					{{examGradItem.examScore}}
				</view>
				<view class="nav">
					<view class="navText">查看</view>
					<u-icon class="enterArrow" name="arrow-right" color="#7f878c" size="28"></u-icon>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		props: ['examGradItem'],
		data() {
			return {}
		},
		methods: {
			handleClick(recordId) {
				if (this.examGradItem.scoreState == 2) {
					this.$emit('checkGrade', recordId)
				}
			}
		},
		computed: {
			state: function() {
				switch (this.examGradItem.scoreState) {
					case 1:
						return "未发布"
						break;
					case 2:
						return "已发布"
						break;
					default:
						return "不存在"
				}
			},
			stateType: function() {
				switch (this.examGradItem.scoreState) {
					case 1:
						return "warning"
						break;
					case 2:
						return "success"
						break;
					default:
						return "info"
				}
			}
		},
	}
</script>

<style lang="scss">
	.examCard {
		box-shadow: 0 0 5px 1px rgba($color: #000000, $alpha: 0.1);
		margin: 15upx;
		border-radius: 15upx;
		padding: 11upx 0;

		.top {
			margin: 0upx 20upx;
			display: flex;
			justify-content: space-around;
			border-bottom: dashed 1px #EEEEEE;

			.title {
				font-size: 36upx;
				font-weight: bold;
				color: #0080d1;
				padding: 15upx 0upx;
			}

			.tag {
				height: 50upx;
				margin: 15upx auto auto 15upx;
			}
		}

		.middle {
			width: 100%;
			margin: 10upx auto 0upx 20upx;
			font-size: $uni-font-size-base;
			color: #7f878c;
			display: flex;

			.left {
				width: 60%;
				line-height: 50rpx;

				text {
					color: #0080d1;
					font-weight: bold;
				}
			}

			.right {
				width: 40%;
				display: flex;
				justify-content: space-between;

				.gradeNum {
					color: #00b060;
					font-size: 80rpx;
				}

				.noGradeNum {
					color: #fed71a;
					font-size: 50rpx;
				}

				.nav {
					display: flex;
					align-items: center;

					.navText {
						color: $font-color-ps;
						margin-right: 5px;
						font-size: 28rpx;
					}

					.enterArrow {
						margin-right: 40rpx;
					}
				}
			}
		}
	}
</style>
